package com.ruoyi.pingjiao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pingjiao.domain.EvaluationItem;
import com.ruoyi.pingjiao.service.IEvaluationItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评教问卷项记录管理Controller
 * 
 * @author 胡浩鹏
 * @date 2022-10-25
 */
@RestController
@RequestMapping("/pingjiao/evaluationItem")
public class EvaluationItemController extends BaseController
{
    @Autowired
    private IEvaluationItemService evaluationItemService;

    /**
     * 查询评教问卷项记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:evaluationItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(EvaluationItem evaluationItem)
    {
        startPage();
        List<EvaluationItem> list = evaluationItemService.selectEvaluationItemList(evaluationItem);
        return getDataTable(list);
    }

    /**
     * 导出评教问卷项记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:evaluationItem:export')")
    @Log(title = "评教问卷项记录管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EvaluationItem evaluationItem)
    {
        List<EvaluationItem> list = evaluationItemService.selectEvaluationItemList(evaluationItem);
        ExcelUtil<EvaluationItem> util = new ExcelUtil<EvaluationItem>(EvaluationItem.class);
        util.exportExcel(response, list, "评教问卷项记录管理数据");
    }

    /**
     * 获取评教问卷项记录管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:evaluationItem:query')")
    @GetMapping(value = "/{evaluationId}")
    public AjaxResult getInfo(@PathVariable("evaluationId") Long evaluationId)
    {
        return AjaxResult.success(evaluationItemService.selectEvaluationItemByEvaluationId(evaluationId));
    }

    /**
     * 新增评教问卷项记录管理
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:evaluationItem:add')")
    @Log(title = "评教问卷项记录管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EvaluationItem evaluationItem)
    {
        return toAjax(evaluationItemService.insertEvaluationItem(evaluationItem));
    }

    /**
     * 修改评教问卷项记录管理
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:evaluationItem:edit')")
    @Log(title = "评教问卷项记录管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EvaluationItem evaluationItem)
    {
        return toAjax(evaluationItemService.updateEvaluationItem(evaluationItem));
    }

    /**
     * 删除评教问卷项记录管理
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:evaluationItem:remove')")
    @Log(title = "评教问卷项记录管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaluationIds}")
    public AjaxResult remove(@PathVariable Long[] evaluationIds)
    {
        return toAjax(evaluationItemService.deleteEvaluationItemByEvaluationIds(evaluationIds));
    }
    @GetMapping("getEvaluationList/{evaluationId}")
    public AjaxResult getEvaluationList(@PathVariable Long evaluationId){
        return AjaxResult.success(evaluationItemService.getEvaluationList(evaluationId));
    }
}
